package com.abc.app.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

/**
 * Page Object for the login page
 * @author betty
 *
 */
public class LoginPage {
    private final WebDriver driver;
 
    public LoginPage(WebDriver driver) {
        this.driver = driver;
    }
     
    public LoginPage setUsername(String username) {
    	By usernameLocator = By.id("user");
        WebElement usernameEl = driver.findElement(usernameLocator);
        usernameEl.clear();
        usernameEl.sendKeys(username);
        return this;
    }
     
    public LoginPage setPassword(String password) {
    	By passwordLocator = By.id("passwd");
        WebElement passwordEl = driver.findElement(passwordLocator);
        passwordEl.clear();
        passwordEl.sendKeys(password);
        return this;
    }
  
    public HomePage clickLoginButton() {
    	By loginButtonLocator = By.id("sign_in");
        driver.findElement(loginButtonLocator).click();
        return new HomePage(driver);
    }
}
